<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <div align="center">
            <h:form>
                <p:dataTable style="width: 1000px" 
                             value="#{controleServico.listaServicos()}" 
                             var="serv" 
                             emptyMessage="Não existe serviços cadastrados" 
                             sortOrder="multiple" 
                             paginator="true" 
                             rows="10">
                    
                <f:facet name="header">
                    Listagem de Serviços
                </f:facet>
                
                <p:column style="max-width: 5px; min-width: 5px; overflow: hidden;text-align: center" 
                          sortBy="#{serv.idServico}" 
                          headerText="Id" 
                          filterMatchMode="startsWith" 
                          filterBy="#{serv.idServico}"
                          filterMaxLength="100"
                          filterStyle="width: 40px">
                    
                    #{serv.idServico}
                </p:column>
  
                <p:column sortBy="#{serv.descricaoServico}" 
                          headerText="Descrição" 
                          filterMatchMode="startsWith" 
                          filterBy="#{serv.descricaoServico}" 
                          filterStyle="width: 300px"
                          style="max-width: 200px; min-width: 200px; overflow: hidden">
                    #{serv.descricaoServico}
                </p:column>
                
                <p:column sortBy="#{serv.preco}" 
                          headerText="Preço" 
                          style="max-width: 20px; min-width: 20px; overflow: hidden;text-align: center">
                    #{serv.preco}
                </p:column>
                
                <p:column style="max-width: 1px; min-width: 1px; overflow: hidden">
                    <p:commandLink action="#{controleServico.excluir()}" style="alignment-adjust: middle">
                        <center><p:graphicImage url="/imagens/del.png"/></center>
                    </p:commandLink>
                </p:column>
                
                <p:column>
                    <p:commandLink action="#{controleServico.editar()}">
                        <center><p:graphicImage url="/imagens/alt.png"/></center>
                        <f:setPropertyActionListener target="#{controleServico.servico}" value="#{serv}"/>
                    </p:commandLink>
                </p:column>
                    
                <f:facet name="footer">
                    <p:commandButton value="Cadastrar" action="#{controleServico.novoServico()}"/>
                    <p:commandButton value="Home" action="#{controleServico.home()}"/>
                </f:facet>
                
              </p:dataTable>
            </h:form>
        </div>
    </h:body>
</html>

